﻿using System;
using System.Linq;
using System.Web.UI;
using GoFishWeb.Models;

namespace GoFishWeb
{
    public class Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated) return;
            using (var db = new GoFishContext())
            {
                if (db.PlayerRecords.Any(x => x.UserName == User.Identity.Name)) return;
                var playerRecord = new PlayerRecord(User.Identity.Name);
                db.PlayerRecords.Add(playerRecord);
                db.SaveChanges();
            }
        }
    }
}